<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>骡窝窝系统管理平台</title>
    <#include "../common/header.ftl"/>

    <script type="text/javascript">
        $(function(){
                //模态框
            $('.showBtn').click(function () {
                var id = $(this).data("tid");
                $.get("/travel/getContentById.do",{id:id},function (data) {
                    console.log(data);
                    $("#textBt").html(data.content);
                });
                $('#showModal').modal('show');
            });
    $('.changeStateBtn').click(function () {
        var id = $(this).data("tid");
        var state = $(this).data("state");
        $.get("/travel/changeStateById.do",{id:id,state:state},function (data) {
            if(data.success){
               window.location.reload();
           }
        });
    });

    //推荐的模态框
            $(".commendBtn").click(function(){
                $('#editForm input').val("");
                var obj=$(this).data("json");
                if(obj){
                    $('#editForm input[name="travelId"]').val(obj.id);
                    $('#editForm input[name="title"]').val(obj.title);
                    $('#editForm input[name="coverUrl"]').val(obj.coverUrl);
                    $('#coverUrl').attr('src',obj.coverUrl);

                }
                $('#commendModal').modal('show')
            });

        });
    </script>
</head>

<body>
<div class="container">
<#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
		<#assign currentMenu = "release" />
				<#include "../common/menu.ftl" />
        </div>
        <div class="col-sm-9">
            <div class="page-header">
                <h3>已发布游记管理</h3>
            </div>

            <div class="row">
                <!-- 提交分页的表单 -->
                <form id="searchForm" class="form-inline" method="post" action="/travelRelease/list.do">
                    <input type="hidden" name="currentPage" id="currentPage" value="1"/>
                    <div class="form-group">
                    </div>
                </form>
            </div>

            <div class="row">
                <table class="table">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>标题</th>
                        <th>封面</th>
                        <th>地点</th>
                        <th>作者</th>
                        <th>状态</th>
                        <th>热门</th>
                        <th></th>
                    </tr>
                    </thead>
                    <tbody>
					<#list pageInfo.list as vo>
                    <tr>
                        <td>${vo_index+1}</td>
                        <td>${vo.title!""}</td>
                        <td><img src='${vo.coverUrl!""}' width="30px"/></td>
                        <td>${vo.place.name!""}</td>
                        <td>${vo.author.nickName!""}</td>
                        <td>
                        <#if vo.state == -1>
                            已拒绝
                        <#elseif vo.state == 0>
                            草稿
                        <#elseif vo.state == 1>
                            待发布
                        <#elseif vo.state == 2>
                            已发布
                        <#elseif vo.state == 3>
                            已发布
                        <#elseif vo.state == 4>
                            已发布
                        </#if>
                        </td>
                        <td>
                        <#if vo.state == 2>
                            否
                        <#elseif vo.state == 3>
                            是
                        <#elseif vo.state == 4>
                            否
                        </#if>
                        </td>
                        <td>
                            <a href="javascript:" class="btn btn-info btn-xs showBtn" data-tid="${vo.id}">
                                <span class="glyphicon glyphicon-pencil"></span> 查看内容
                            </a>
                        <a href="javascript:" class="btn btn-primary  btn-xs changeStateBtn" data-tid="${vo.id}" data-state="1">
                            <span class="glyphicon glyphicon-pencil"></span> 取消发布
                        </a>
                            <a href="javascript:" class="btn btn-primary  btn-xs changeStateBtn" data-tid="${vo.id}" data-state="3">
                            <span class="glyphicon glyphicon-pencil"></span> 热门
                        </a>
                        <a href="javascript:" class="btn btn-primary  btn-xs commendBtn" data-json='${vo.json}' >
                            <span class="glyphicon glyphicon-pencil"></span> 推荐
                        </a>
                       </td>
                    </tr>
					</#list>
                    </tbody>
                </table>
               <#include "../common/page.ftl"/>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="showModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">查看内容</h4>
            </div>
            <div class="modal-body" id=textBt>

            </div>

        </div>
    </div>
</div>
<style>
    #showModal img{
        width:100%
    }
    #showModal  .modal-body{
        max-height: 600px;
        overflow-y: auto;
    }

</style>

<div class="modal fade" id="commendModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">游记修改</h4>
            </div>
            <div class="modal-body">

                <form class="form-horizontal" action="/travelCommend/saveOrUpdate.do" method="post" id="editForm" enctype="multipart/form-data">
                    <input type="hidden"  name="travelId">
                    <div class="form-group" >
                        <label for="name" class="col-sm-4 control-label">标题：</label>
                        <div class="col-lg-7">
                            <input type="text" class="form-control"  name="title" >
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">封面：</label>
                        <div class="col-lg-7">
                            <img id="coverUrl" width="100%">
                            <input type="file" class="form-control"  name="file" >
                            <input type="hidden" class="form-control"  name="coverUrl" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">副标题：</label>
                        <div class="col-lg-7">
                            <input type="text" class="form-control"  name="subTitle"  >
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">推荐时间：</label>
                        <div class="col-lg-7">
                            <input type="text" class="form-control"  name="schedule"  onclick="WdatePicker()">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">推荐类型：</label>
                        <div class="col-lg-7">
                            <select class="c-select form-control" name="type" >
                                <option value="1">每周推荐</option>
                                <option value="2">每月推荐</option>
                                <option value="3">攻略推荐</option>
                            </select>
                        </div>
                    </div>

                </form>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary submitBtn">保存</button>
            </div>
        </div>
    </div>

</div>


</body>
</html>